package org.demo.patten.visitor;

/**
 * @author zhuj
 * @date 2025/3/29
 * @apiNote
 */
public class SizeCalculatorVisitor implements Visitor {
    private int totalSize = 0;
    public void visit(File file) {
        totalSize += file.getSize();
    }
    public void visit(Folder folder) {
        for (FileSystemElement element : folder.getChildren()) {
            element.accept(this);
        }
    }
    public int getTotalSize() {
        return totalSize;
    }
}